package com.qfedu.controller;

import com.github.pagehelper.PageInfo;
import com.qfedu.entity.Employee;
import com.qfedu.service.EmployeeService;
import com.qfedu.util.PageHelperUtil;
import com.qfedu.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * projectName: logistics
 * author: CGY
 * time: 2020/10/9 21:09
 * description:
 */
@RestController
@RequestMapping("/employee")
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;

    @RequestMapping("/selectAllEmp.do")
    public PageHelperUtil selectAllEmp(){
        PageInfo pageInfo = employeeService.selectAll();
        return PageHelperUtil.success(pageInfo.getTotal(),pageInfo.getList());
    }
    @RequestMapping("/addEmp.do")
    public Result addEmp(Employee employee){
        Result ret = employeeService.addEmp(employee);
        return ret;
    }

    @RequestMapping("/selectEmpByCode.do")
    public Result selectEmpByCode(String employeeCode){
        Result ret = employeeService.selectEmpByCode(employeeCode);
        return ret;
    }

    @RequestMapping("/updateEmp.do")
    public Result updateEmp(Employee employee){
        System.out.println("employee = " + employee);
        Result ret = employeeService.updateEmp(employee);
        return ret;
    }
}
